package databases

import (
	"Godzilla/common/ini"
	"log"
)

var etcdMap = make(map[string]string)

func GetEtcdConfig(str string) string {

	return etcdMap[str]
}

func SetEtcdConfig(key string, value string) bool {
	etcdMap[key] = value
	if _, err :=etcdMap[key]; err == false {
		return false
	}
	return true
}

func EtcdSetConfig() bool {
	var (
		Host 	string
		Port	string
	)

	driver := "etcd"

	cfg, err := ini.NewIni()
	if err != nil {
		log.Println(err)
		return false
	}

	Host = cfg.Section(driver).Key("Host").String()
	Port = cfg.Section(driver).Key("Port").String()

	SetEtcdConfig("Host",Host)
	SetEtcdConfig("Port", Port)

	return true

}